Code "Drop Dash Over Spin Dash" in "Gameplay" by "Weezley" 
//
	#include "ReflectionHelpers" noemit

    #lib "Sonic"
	#lib "SonicParameters"
    #lib "BlackboardStatus"

    #load "System.Numerics.dll"

    using System.Numerics;

    static bool IsVelocityAdded = false;
    static float chargeCount = 1.0f;
//
{
    Sonic.State.Redirect(Sonic.StateID.StateSpinBoost, Sonic.StateID.StateDropDash);

    var currentState = Sonic.State.GetCurrentStateID();
    var previousState = Sonic.State.GetPreviousStateID();

    if (!Sonic.IsGrounded() && BlackboardStatus.IsCyberSpace())
    {
        Sonic.State.Discard(Sonic.StateID.StateSpinBoostCharge);
    }
    else
    {
        Sonic.State.Restore(Sonic.StateID.StateSpinBoostCharge);
    }

    if (!Sonic.IsGrounded() && !BlackboardStatus.IsCyberSpace())
    {
        Sonic.State.Redirect(Sonic.StateID.StateSpinBoostCharge, Sonic.StateID.StateSonicBoomKick)
    }
    else
    {
        Sonic.State.Redirect(Sonic.StateID.StateSpinBoostCharge, Sonic.StateID.StateSpinBoostCharge)
    }

    if (Sonic.Kinematics.GetHorizontalMagnitude() >= 20.0f) 
    {
	Sonic.State.Discard(Sonic.StateID.StateSpinBoostCharge)
    }

    if (Sonic.Input.IsPressed(Sonic.PlayerActionType.PlayerSonicboom) && (Sonic.State.GetCurrentStateID() == Sonic.StateID.StateSpinBoostCharge) && chargeCount < 6)
    {
        chargeCount += 1;
    }
    else if (Sonic.State.GetCurrentStateID() == Sonic.StateID.StateSpinBoostCharge && chargeCount > 1)
    {
        chargeCount -= 0.015f;
    }

    if (previousState == Sonic.StateID.StateSpinBoostCharge && currentState == Sonic.StateID.StateSpinBoost)
    {
        if (!IsVelocityAdded && !BlackboardStatus.IsCyberSpace() && !Sonic.IsSideView())
        {
            var kinematics = Sonic.Kinematics.Get();

            if (kinematics == null)
                return;

            *kinematics.Velocity += Sonic.Kinematics.GetForward() * (chargeCount * 6.0f + 15.0f);

            IsVelocityAdded = true;

            goto Reset;
        }

        if (!IsVelocityAdded && BlackboardStatus.IsCyberSpace() && !Sonic.IsSideView())
        {
            var kinematics = Sonic.Kinematics.Get();

            if (kinematics == null)
                return;

            *kinematics.Velocity += Sonic.Kinematics.GetForward() * (chargeCount * 9.0f + 20.0f);

            IsVelocityAdded = true;

            goto Reset;
        }

	if (!IsVelocityAdded && Sonic.IsSideView())
        {
            var kinematics = Sonic.Kinematics.Get();

            if (kinematics == null)
                return;

            *kinematics.Velocity += Sonic.Kinematics.GetForward() * (chargeCount * 4.0f + 15.0f);

            IsVelocityAdded = true;

            goto Reset;
        }
        Reset:
            chargeCount = 1;
    }
    else
    {
        IsVelocityAdded = false;
    }

    if (Sonic.State.GetCurrentStateID() != Sonic.StateID.StateSpinBoostCharge)
    {
        chargeCount = 1;
    }

    if (currentState == Sonic.StateID.StateSpringJumpHeadLand)
    {
        var kinematics = Sonic.Kinematics.Get();

        if (kinematics != null)
        {
            float dotProduct = Vector3.Dot(Vector3.Transform(Vector3.UnitY, *kinematics.Rotation), Vector3.UnitY);

            if (dotProduct < 0.01f)
                Sonic.State.SetState(Sonic.StateID.StateRun);
	}
    }

    bool isBoostPressed = Sonic.Input.IsPressed(Sonic.PlayerActionType.PlayerBoost);
    bool isStompPressed = Sonic.Input.IsPressed(Sonic.PlayerActionType.PlayerStomping);

    if ((currentState == Sonic.StateID.StateSpinBoost || currentState == Sonic.StateID.StateDropDash) && isStompPressed)
    {
        Sonic.State.SetState(Sonic.IsGrounded() ? Sonic.StateID.StateSpringJumpHeadLand : Sonic.StateID.StateFall);
    }
    else if (!Sonic.IsGrounded() && (currentState == Sonic.StateID.StateSpinBoost || currentState == Sonic.StateID.StateDropDash) && isBoostPressed)
    {
        Sonic.State.SetState(Sonic.StateID.StateBumpJump);
    }

    if (Sonic.IsSideView())
    {
        WriteProtected<byte>
        (
            ScanSignature
            (
                "\x74\x10\x0F\x28\xCF",
                "xxxxx"
            ),

            0xEB
        )
    }
    else
    {
        WriteProtected<byte>
        (
            ScanSignature
            (
                "\x74\x10\x0F\x28\xCF",
                "xxxxx"
            ),

            0x74, 0x10, 0x0F, 0x28, 0xCF
        )
    }

    var SonicParametersInfo = Reflection.GetDataInfo<SonicParameters.Root>("player_common");

	if (SonicParametersInfo.pData == null)
		return;

	RFL_SET_PARAM(SonicParametersInfo, forwardView.dropDash.brake, -0.1f);
	RFL_SET_PARAM(SonicParametersInfo, forwardView.dropDash.steeringSpeed1, 400.0f);
	RFL_SET_PARAM(SonicParametersInfo, forwardView.dropDash.steeringSpeed2, 200.0f);
    RFL_SET_PARAM(SonicParametersInfo, forwardView.dropDash.checkDashSpeed, 10.0f);
    RFL_SET_PARAM(SonicParametersInfo, cyberspace.dropDash.brake, -0.1f);
	RFL_SET_PARAM(SonicParametersInfo, cyberspace.dropDash.steeringSpeed1, 400.0f);
	RFL_SET_PARAM(SonicParametersInfo, cyberspace.dropDash.steeringSpeed2, 200.0f);
    RFL_SET_PARAM(SonicParametersInfo, cyberspace.dropDash.checkDashSpeed, 10.0f);
    RFL_SET_PARAM(SonicParametersInfo, cyberspaceSV.dropDash.brake, -0.1f);
	RFL_SET_PARAM(SonicParametersInfo, cyberspaceSV.dropDash.steeringSpeed1, 400.0f);
	RFL_SET_PARAM(SonicParametersInfo, cyberspaceSV.dropDash.steeringSpeed2, 200.0f);
    RFL_SET_PARAM(SonicParametersInfo, cyberspaceSV.dropDash.checkDashSpeed, 10.0f);
}

Patch "Disable Drop Dash Turning Delay" in "Physics" by "Hyper"
{
    WriteNop
    (
        /* 0x14084323B */
        ScanSignature
        (
            "\x73\x19\x48\x8B\x47\x40",
            "xxxxxx"
        ),

        2
    );
}

Code "Retain Ground Velocity for Jump" in "Physics" by "Hyper" does 
/*
Retains Sonic's ground velocity when jumping.

Notes;
- This will allow you to retain velocity when jumping out of a Drop Dash.
- The "Jump Deceleration" and "Maintain boost during a jump" options can remain active without conflicting with this code.
*/
//
    #lib "Memory"
    #lib "Sonic"

    static bool IsInitialised = false;
    static bool IsStateJump = false;
//
{
    if (!IsInitialised)
    {
        fixed (bool* pIsStateJump = &IsStateJump)
        {
            /* v1.30: 0x1408406F8 */
            var callerFuncAddr = ScanSignature
            (
                "\xE8\xCC\xCC\xCC\xCC\x48\x8B\x43\x20\xBA\x20\x16\x1E\x71\x44\x0F\x28\xC0\x48\x8B\x88\x80\x00\x00\x00\xE8\xCC\xCC\xCC\xCC\x48\x8B\xC8\xE8\xCC\xCC\xCC\xCC\x48\x8B\xCB\x0F\x28\xF8\xE8\xCC\xCC\xCC\xCC\x48\x8B\xC8\xE8\xCC\xCC\xCC\xCC\x48\x8D\x55\xE7",
                "x????xxxxxxxxxxxxxxxxxxxxx????xxxx????xxxxxxx????xxxx????xxxx"
            );

            /* v1.30: 0x14080CA10 */
            var mainFuncAddr = Memory.ReadCall(callerFuncAddr);

            // Update posture to allow retaining ground velocity.
            WriteAsmHook
            (
                $@"
                    mov   rdi, rcx

                    ; Check if we're in the jump state
                    push  r11
                    mov   r11, {(long)pIsStateJump}
                    mov   r11b, byte ptr [r11]
                    cmp   r11b, 0
                    jz    default
                    mov   al, 1
                    jmp   exit

                default:
                    xor   edx, edx
                    mov   rcx, [rcx + 0x28] ; RCX = BlackboardStatus
                    mov   eax, edx
                    and   eax, 0x3F
                    movzx r8d, al
                    mov   eax, edx
                    shr   rax, 6
                    mov   rax, [rcx + rax * 8 + 0x30]
                    bt    rax, r8
                    setb  al

                exit:
                    pop   r11
                ",

                /* v1.30: 0x14080CA16 */
                mainFuncAddr + 6,

                HookBehavior.Replace
            );
        }

        IsInitialised = true;
    }

    void NotifyStateJump(Sonic.StateID stateId, Sonic.StateID[] stateStackTrace)
    {
        IsStateJump = (stateId == Sonic.StateID.StateJump) || (stateId == Sonic.StateID.StateGrindJump);
    }

    Sonic.State.AddStateNotifyAction(NotifyStateJump);
}

Code "Aerial Homing Attack" by "Lex"
///
	#lib "Sonic"
///

if (Sonic.IsGroundedSpecial() && !(Sonic.State.GetCurrentStateID() == Sonic.StateID.StateParry || Sonic.State.GetCurrentStateID() == Sonic.StateID.StateQuickCyloop))
     {
       Sonic.State.Discard(Sonic.StateID.StateHomingAttack);
     }
     else
     {
       Sonic.State.Restore(Sonic.StateID.StateHomingAttack);
     }

Code "Visual Effects" in "Physics" by "Proto" 
//
    #include "ReflectionHelpers" noemit

    #lib "SonicParameters"
    #lib "Sonic"
    #lib "BlackboardStatus"
    #lib "Bitwise"
    #lib "Reflection"

    #load "System.Numerics.dll"

    using System;
    using System.Numerics;

    static bool isWind = false;
    static bool isDust = false;
    static bool isCyber = false;
//
{
    var kinematics = Sonic.Kinematics.Get();

    if (kinematics == null)
        return;

    float currentSpeed = Sonic.Kinematics.GetHorizontalMagnitude();
    float currentVSpeed =  0.0f;

    if ((currentSpeed >= 50.0f || currentSpeed >= 35.0f && Sonic.IsSideView()) && !BlackboardStatus.IsCyberSpace())
    {
        if (!isWind)
        {
            Sonic.Effect.PlayEffect("Wind", "ef_ft_dash_ge01")
            Sonic.Effect.PlayEffect("Wind", "ef_ft_dash_ge01")
            isWind = true;
        }
    }
    else
        {
        Sonic.Effect.StopEffect("Wind");
        isWind = false;
    }

    if ((currentSpeed >= 50.0f || currentSpeed >= 35.0f && Sonic.IsSideView()) && Sonic.State.GetCurrentStateID() == Sonic.StateID.StateRun && !BlackboardStatus.IsCyberSpace())
    {
        if (!isDust)
        {
            Sonic.Effect.PlayEffect("Dust", "ef_ft_spinboost_charge01_sa01")
            isDust = true;
        }
    }
    else 
        {
        Sonic.Effect.StopEffect("Dust");
        isDust = false;
    }

    if ((currentSpeed >= 61.0f || currentSpeed >= 35.0f && Sonic.IsSideView()) && BlackboardStatus.IsCyberSpace())
    {
        if (!isCyber)
        {
            Sonic.Effect.PlayEffect("Cyber", "ec_so_skill_psycho_aura01_lightning01")
            Sonic.Effect.PlayEffect("Cyber", "ec_so_skill_psycho_aura01_linepar01")
            isCyber = true;
        }
    }
    else 
        {
        Sonic.Effect.StopEffect("Cyber");
        isCyber = false;
    }

}

Code "Adventure Spindash" By "Lex"
///
    #lib "SonicParameters"
    #lib "Sonic"
    #lib "Bitwise
    #lib "BlackboardStatus"
    #include "ReflectionHelpers" noemit

    static bool isSpindash = false;
///

if (Sonic.State.GetCurrentStateID() == Sonic.StateID.StateDropDash || Sonic.State.GetCurrentStateID() == Sonic.StateID.StateSpinBoost)
{
    if(!isSpindash)
    {
      Sonic.Effect.PlayEffect("Spindash", "ec_ft_pow_dash_ge01_blue_line01")
      isSpindash = true;
    }
}
else
{
    isSpindash = false;
    Sonic.Effect.StopEffect("Spindash")
}

Code "Brake" By "Lex"
//
     #lib "Sonic"
//

if (Sonic.State.GetCurrentStateID() == Sonic.StateID.StateSliding && Sonic.Input.IsReleased(Sonic.PlayerActionType.PlayerStomping))
    {
        Sonic.State.SetState(Sonic.State.GetPreviousStateID());
    }

Code "Blue Homing Attack and Stomp Trail" in "Animation" by "Weezley" 
//
    #lib "Sonic"
    #lib "BlackboardStatus"

    static bool stompPlayed = false;
    static bool homingPlayed = false;
//
{
    if (Sonic.State.GetCurrentStateID() == Sonic.StateID.StateHomingAttack || Sonic.State.GetCurrentStateID() == Sonic.StateID.StateHomingAttackInStorm)
    {
        if (!homingPlayed)
        {
            Sonic.Effect.PlayEffect("Homing Line", BlackboardStatus.IsSuper() ? "ec_ss_stomp_locus01" : "ec_so_stomp_locus01")
            Sonic.Animation.SetAnimation("JUMP_BALL");
            homingPlayed = true;
        }
    }
    else
    {
        homingPlayed = false;
        Sonic.Effect.StopEffect("Homing Line");
    }


    if (Sonic.State.GetCurrentStateID() == Sonic.StateID.StateStompingDown && !BlackboardStatus.IsSuper())
    {
        if (!stompPlayed)
        {
            Sonic.Effect.PlayEffect("Stomp Line", "ec_ft_pow_dash_ge01_round_blue01")
            Sonic.Effect.PlayEffect("Stomp Line", "ec_ft_pow_dash_ge01_round_blue01")
            Sonic.Effect.PlayEffect("Stomp Line", "ec_ft_pow_dash_ge01_round_blue01")
            stompPlayed = true;
        }
    }
    else
    {
        stompPlayed = false;
        Sonic.Effect.StopEffect("Stomp Line")
    }
}

Code "Disable Parry" By "Lex"
//
    #lib "Sonic"
    #lib "BlackboardStatus
    #lib "Lua"
//
{
if (!(BlackboardStatus.IsSuper() || Sonic.State.GetCurrentStateID() == Sonic.StateID.StateBatterBox))
    {
        Sonic.State.Discard(Sonic.StateID.StateParry);
    }
    else
    {
        Sonic.State.Restore(Sonic.StateID.StateParry);
    }
}

Patch "Fix Damage from Jumping into Enemies" in "Fixes" by "Hyper" does "Fixes Sonic taking damage when jumping into enemies within a small frame window." 
//
    #lib "Sonic"
    #lib "BlackboardStatus"

    static bool IsJumpPrevious = false;
//
{
    void NotifyJumpDamageCollision(Sonic.StateID stateId, Sonic.StateID[] stateStackTrace)
    {
        bool isJump = stateId == Sonic.StateID.StateJump ||
            stateId == Sonic.StateID.StateDoubleJump ||
            stateId == Sonic.StateID.StateGrindDoubleJump;

    if (BlackboardStatus.IsCyberSpace())
    {
        if (isJump)
        {
            Sonic.Collision.SetCollisionSphere(Sonic.CollisionType.Damage, 1.0f);
            Sonic.Collision.ToggleEntityCollision(false);
            IsJumpPrevious = true;
        }
        else if (IsJumpPrevious)
        {
            Sonic.Collision.SetCollisionSphere(Sonic.CollisionType.Default, 1.0f);
            Sonic.Collision.ToggleEntityCollision(true);
            IsJumpPrevious = false;
        }
        else
        {
            IsJumpPrevious = false;    
        }
    }
}

    Sonic.State.AddStateNotifyAction(NotifyJumpDamageCollision);
}

Code "Better Badnik Bounce" By "Lex"
//
    #lib "Sonic"
//
{
    if (Sonic.State.GetCurrentStateID() == Sonic.StateID.StateSpinAttack)
    {
         Sonic.State.SetState(Sonic.StateID.StateDoubleJump);
    }
}

Code "Disable Ground Boost" By "Lex"
//
    #lib "Sonic"
    #lib "Lua"
//
{
    Lua.Init();
    {    
     if (Sonic.IsGrounded() && (Sonic.State.GetCurrentStateID() != Sonic.StateID.StateWallMove))
    {
        Lua.Call("SetPlayerAbilityEnabled", "Boost", false);
    }
    else
    {
        Lua.Call("SetPlayerAbilityEnabled", "Boost", true);
        }
    }
}

Code "Reanimated" By "Lex"
//
    #lib "Sonic"
//
{
    if (Sonic.State.GetCurrentStateID() == Sonic.StateID.StateAirBoost)
    {
        Sonic.Effect.StopAnimationEffects();
        Sonic.Animation.SetAnimation("JUMP_BALL");
    }

    if (Sonic.State.GetCurrentStateID() == Sonic.StateID.StateSliding)
    {
        Sonic.Animation.SetAnimation("RUN_SLIP_FRONT_LOOP");
    }

    if (Sonic.State.GetCurrentStateID() == Sonic.StateID.StateChargeAttack)
    {
        Sonic.Animation.SetAnimation("COMBO_CHARGE_LOOP");
    }
}